package com.aop.springbootaop.service;

import com.aop.springbootaop.entity.User;
import com.aop.springbootaop.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserMongoService {
    @Autowired
    private UserRepository userRepository;

    @Autowired
    private MongoTemplate mongoTemplate;

    public User selectByName(String name) {
        return userRepository.selectByName(name);
    }

    public List<User> findAll() {
        return userRepository.findAll();
    }

    public List<User> findAllFromMongoTemplate() {
        return mongoTemplate.findAll(User.class);
    }
}
